import { drawerConfig } from "./drawer";
import { modalConfig } from "./modal";
import { searchConfig } from "./search";
import { tableConfig, tableData, tableLoading, tablePage } from "./table";
const queryParams = reactive<any>({});
export const fetchList = async () => {
  try {
    tableData.value.length = 0;
    tableLoading.value = true;
    queryParams.page = tablePage.current;
    queryParams.page_size = tablePage.pageSize;
    // await handleApiTask(tableActiveKey.value);
  } catch (error: any) {
    message.error(error.message);
  } finally {
    tableLoading.value = false;
  }
};
export const refreshTable = async (searchParams = {}) => {
  tablePage.current = 1;
  initObjAttr(queryParams, searchParams);
  await fetchList();
};
export default defineComponent({
  setup(props, { attrs, emit, expose, slots }) {
    const defineSearch = searchConfig();
    const defineDrawer = drawerConfig();
    const defineModal = modalConfig();
    const defineTable = tableConfig();
    return () => (
      <s-design
        defineSearch={defineSearch}
        defineTable={defineTable}
        defineDrawer={defineDrawer}
        defineModal={defineModal}
      />
    );
  },
});
